package com.ruoyi.classai.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ruoyi.classai.domain.AnalysisModeRel;
import com.ruoyi.classai.domain.EwcAnalysismodeRel;
import com.ruoyi.classai.domain.QueryAiMsg;
import com.ruoyi.classai.mapper.EwcAnalysismodeRelMapper;
import com.ruoyi.classai.service.EwcAnalysismodeRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EwcAnalysismodeRelServiceImpl extends ServiceImpl<EwcAnalysismodeRelMapper, EwcAnalysismodeRel> implements EwcAnalysismodeRelService {
@Autowired
private EwcAnalysismodeRelMapper ewcAnalysismodeRelMapper;
    @Override
    public boolean saveIfNotExists(EwcAnalysismodeRel entity) {
        QueryWrapper<EwcAnalysismodeRel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("task_id", entity.getTaskId());
        // 根据 task_id 查询数据是否存在
        boolean exists = this.count(queryWrapper) > 0;
        if (!exists) {
            // 不存在则保存数据
            return this.save(entity);
        }
        return false;
    }

    @Override
    public EwcAnalysismodeRel getByTaskId(AnalysisModeRel analysisModeRel) {
        QueryWrapper<EwcAnalysismodeRel> updateWrapper = new QueryWrapper<>();
        updateWrapper.eq("task_id", analysisModeRel.getTask_id());
        return this.getOne(updateWrapper);
    }


}